//
//  Do Specified JavaScript in Current Webpage.m
//  Do Specified JavaScript in Current Webpage
//
//  Created by itod on 3/30/07.
//  Copyright 2007 Todd Ditchendorf. All rights reserved.
//

#import "Do Specified JavaScript in Current Webpage.h"


@implementation Do_Specified_JavaScript_in_Current_Webpage

#pragma mark -
#pragma mark AbstractMethods

- (NSString *)javaScriptSource
{
	NSMutableString *jsSource = [NSString stringWithContentsOfFile:[self javaScriptFilePath]];
	jsSource = [NSString stringWithFormat:jsSource, [self atomicInput]];
	jsSource = [NSMutableString stringWithString:jsSource];
	[jsSource replaceOccurrencesOfString:@"\"" withString:@"\\\"" options:nil range:NSMakeRange(0, [jsSource length])];
	return jsSource;
}


- (NSString *)javaScriptFilePath
{
	NSString *filename = @"DoSpecifiedJavaScript";
	NSBundle *bundle = [NSBundle bundleForClass:[self class]];
	return [bundle pathForResource:filename ofType:@"js" inDirectory:@"JavaScript"];
}


@end
